#version 460
#extension GL_GOOGLE_include_directive : enable
#extension GL_EXT_shader_explicit_arithmetic_types_int64 : require

#include "../../../../core/shader_std.h" 

layout(location = 0) in vec4 vColor;
layout(location = 1) in vec3 vNormal;
layout(location = 2) in flat uint vShaderType;
layout(location = 3) in vec3 vLigth[3];

layout(location=0) out vec4 outColor;

layout(early_fragment_tests) in;

void main(void){
	
	switch(vShaderType){
		case DEF_3DShaderType_PerVertexColor : {
			vec2 pt = ((gl_PointCoord.xy - 0.5) * 2.5);
			float d = (1 - dot(pt, pt)) * 5;
			if(d > 0){
				outColor = vec4(vColor.rgb, d);
			}
			else{
				discard;
			}
			break;
		}
		default:{
			//vec3 vLigthColor[3] = {
			//	vec3(0.7,0.7,0.7),
			//	vec3(0.1,0.2,0.3),
			//	vec3(0.1,0.2,0.5),
			//};
			float vLigthIntensity[3] = {
				1.0,
				0.6,
				0.4,
			};


			outColor = vColor;
			float d = 0;
			for(uint i=0; i<3; ++i){
				d += abs(dot(vLigth[i], vNormal)) * vLigthIntensity[i];
			}
			outColor.rgb *= d * 0.7;
			break;
		}
	}
}



